package com.bigdata.utils;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Component;
import org.springframework.util.ClassUtils;
import org.springframework.util.ResourceUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.context.ServletContextAware;

import java.io.FileNotFoundException;
import java.net.URL;

public class GetBasePath {


    public static String getRealPath(HttpServletRequest request) {
        String path = request.getSession().getServletContext().getRealPath("/");
        String xg = path.substring(path.length() - 1);
        if (!xg.equals("/")) {
            path = path + "/";
        }
        return path;
    }

    public static String getWebPath() throws FileNotFoundException {
        String path = ResourceUtils.getURL("classpath:").getPath();
        String xg = path.substring(path.length() - 1);
        if (!xg.equals("/")) {
            path = path + "/";
        }
        return path;
    }

    public static void main(String[] args) {
        System.out.println(String.format("%02d", 9));

    }
}
